package com.example.tccdemo.service;

import com.example.tccdemo.db164.dao.OrderMapper;
import com.example.tccdemo.db164.model.Order;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;

/**
 * @author caryguan
 * @version V1.0
 * @Package com.example.tccdemo.service
 * @date 2020/10/15 21:51
 */

@Service
public class OrderService {

    @Resource
    private OrderMapper orderMapper;

    /**
     *
     * @param orderId
     * @return 1订单不存在 0代表成功
     */
    public int handleOrder(int orderId){
        Order order = orderMapper.selectByPrimaryKey(orderId);
        if (order==null){
            return 1;
        }
        order.setOrderStatus(1);//已支付
        order.setUpdateTime(new Date());
        order.setUpdateUser(0);//设置为0代表系统更新
        orderMapper.updateByPrimaryKey(order);

        return 0;
    }
}